package com.lzw.config;

import com.lzw.app.ServerApp;
import com.lzw.property.LzwProperties;
import com.lzw.property.ServerProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * 配置类
 * @author LZW
 */
@Configuration
@EnableConfigurationProperties({LzwProperties.class, ServerProperties.class})
public class ServerAutoConfiguration {
    //启动应用
    @Bean
    @ConditionalOnMissingBean(ServerApp.class)
    public ServerApp serverApp(ServerProperties serverProperties,LzwProperties lzwProperties) throws IOException {
        return ServerApp.getInstance(lzwProperties,serverProperties);
    }
}
